<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta http-equiv="pragram" content="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>[title]</title>
    <link href="/Public/Home/css/style.css" rel="stylesheet" type="text/css">
    <link href="/Public/Home/css/iconfont.css" rel="stylesheet" type="text/css">
    <script src="/Public/Home/js/jquery-1.11.1.min.js"></script>
    <script src="/Public/Home/js/publicjquery.js"></script>
    <script src="/Public/Home/js/layer/layer.js" ></script>
    <script src="/Public/Home/js/common.js" ></script>
    <script src="/Public/Home/js/ajaxfileupload.js" ></script>
</head>
<body onselectstart="return false">
<div class="main FromUpToDown" >
    <div class="content" style="position: relative">
        <div class="head-content">
            <div class="head-title">
                <span><?php echo ACTION_NAME == 'edit' ? '修改' : '添加';?>用户</span>
            </div>
        </div>
        <form action='' id="form" >
        <div class="form-content">
            <div class="form">
                <div class="form-left">用户名</div>
                <div class="form-right">
                    <input class="form-input-small" type="text" name='name'  value="<?php echo ($info['name']); ?>" placeholder="用户名"  />
                </div>
            </div>
            <div class="form">
                <div class="form-left">密码</div>
                <div class="form-right">
                    <input class="form-input-small" type="text" name='pass'  value="" placeholder="密码"  />
                </div>
            </div>
            <div class="form">
                <div class="form-left">手机号</div>
                <div class="form-right">
                    <input class="form-input-small" type="text" name='phone'  value="<?php echo ($info['phone']); ?>" placeholder="手机号"  />
                </div>
            </div>
            <div class="form">
                <div class="form-left">网点ID</div>
                <div class="form-right">
                    <input class="form-input-small" type="text" name='roleid'  value="<?php echo ($info['roleid']); ?>" placeholder="网点ID" />
                </div>
            </div>
            <div class="form">
                <div class="form-left">快递点名称</div>
                <div class="form-right">
                    <input class="form-input-small" type="text" name='express_name'  value="<?php echo ($info['express_name']); ?>" placeholder="快递点名称" />
                </div>
            </div>
            <div class="form">
                <div class="form-left">快递点地址</div>
                <div class="form-right">
                    <textarea name="addr" cols="30" rows="5"><?php echo ($info['addr']); ?></textarea>
                </div>
            </div>
            <div class="form">
                <div class="form-left">负责人</div>
                <div class="form-right">
                    <input class="form-input-small" type="text" name='header'  value="<?php echo ($info['header']); ?>" placeholder="负责人"  />
                </div>
            </div>
            <div class="form">
                <div class="form-left">用户角色</div>
                <div class="form-right">
                    <select class="form-input-small" name="group_id" >
                        <option value="">选择角色</option>
                        <?php if(is_array($group)): foreach($group as $key=>$vo): ?><option <?php echo $vo['id']== $info['group_id'] ? 'selected' : '';?> value="<?php echo ($vo['id']); ?>"><?php echo ($vo['title']); ?></option><?php endforeach; endif; ?>
                    </select>
                </div>
            </div>
                <input type='hidden' name='id' value="<?php echo ($info['id']); ?>" >
                <div class="form-operate">
                    <button type='button' id="save"  class="form-button color-bg-green">保存</button>
                    <button type='button' onclick="history.go(-1)" class="form-button color-bg-grey">返回</button>
                </div>
        </div>
        </form>
    </div>
</div>
<div class="main-foot">Copyright  2013-2015 WeiGouTong.com. All Rights Reserved.  苏ICP备09098830号</div>
<script>
    $("#save").click(function(){

        if($("input[name='name']").val() == ''){
            layer.tips('请输入用户名！', 'input[name="name"]', {tips: [2, 'red'], time: 1000});
            return;
        }
        var reg = /1[3578]\d{9}/;
        if(!reg.test($("input[name='phone']").val())){
            layer.tips('请填写合理手机号！', 'input[name="phone"]', {tips: [2, 'red'], time: 1000});
            return;
        }
        if($("input[name='roleid']").val() == '' || $("input[name='roleid']").val() == '0' ){
            layer.tips('请输入网点ID！', 'input[name="roleid"]', {tips: [2, 'red'], time: 1000});
            return;
        }
		
        if($("input[name='express_name']").val() == ''){
            layer.tips('请输入快递点名称！', 'input[name="express_name"]', {tips: [2, 'red'], time: 1000});
            return;
        }
		if($("textarea[name='addr']").val() == ''){
            layer.tips('请输入快递点地址！', 'textarea[name="addr"]', {tips: [2, 'red'], time: 1000});
            return;
        }
        if($("input[name='header']").val() == ''){
            layer.tips('请输入负责人！', 'input[name="header"]', {tips: [2, 'red'], time: 1000});
            return;
        }
        $("#save").attr('disabled',true);
        $.post(
                "<?php echo U('save');?>",
                 $("#form").serialize(),
                function(res){
                    if(res.status == 1){
                        layer.tips(res.info, '#save', {tips: [2, 'green'], time: 1000});
                        setTimeout("location.href = document.referrer",1000);
                    }else{
                        $("#save").attr('disabled',false);
                        layer.tips(res.info, '#save', {tips: [2, 'red'], time: 1000});
                    }
                }
        );
    });
</script>
</body>
</html>